{% extends 'AdminsBundle:base:main.content.lists.div.html.twig' %}
{% set choices = {"isWebIndex":"首页推荐","isNew":"新品推荐","isHot":"热卖推荐","isSale":"折扣推荐","isFamous":"品牌推荐"} %}
{% block options %}
    <div class="menu-list">
        <div class="rule-single-select">
            <select name="cond[cid]" onchange="javascript:__doPostBack('searchCond','')" >
                <option value="" {{app.request.get("cond").cid is defined and app.request.get("cond").cid == "" ? ' selected="selected"' : "" }} >请选择分类</option>
                {% for class in classes %}
                    <option value="{{ class.id }}" {{app.request.get("cond").cid is defined and  app.request.get("cond").cid == class.id ? ' selected="selected"' : "" }} >{{ class.name }}</option>
                {% endfor %}
            </select>
        </div>
        <div class="rule-multi-checkbox">
            <span>
                {% for key,val in choices %}
                    <label><input type="checkbox" name="cond[{{ key }}]" value="1" onchange="javascript:__doPostBack('searchCond','')"  {{app.request.get("cond")[key] is defined and  app.request.get("cond")[key] == 1 ? ' checked="checked"' : "" }} >{{ val }}</label>
                {% endfor %}
                {#<label><input type="checkbox" name="cond[isHot]" value="1" onchange="javascript:__doPostBack('searchCond','')"  {{app.request.get("cond").isHot is defined and  app.request.get("cond").isHot == 1 ? ' checked="checked"' : "" }} >热卖</label>#}
                {#<label><input type="checkbox" name="cond[isHot]" value="1" onchange="javascript:__doPostBack('searchCond','')"  {{app.request.get("cond").isHot is defined and  app.request.get("cond").isHot == 1 ? ' checked="checked"' : "" }} >热卖</label>#}
                {#<label><input type="checkbox" name="cond[isNew]" value="1" onchange="javascript:__doPostBack('searchCond','')"  {{app.request.get("cond").isNew is defined and  app.request.get("cond").isNew == 1 ? ' checked="checked"' : "" }} >新品</label>#}
                {#<label><input type="checkbox" name="cond[isSale]" value="1" onchange="javascript:__doPostBack('searchCond','')"  {{app.request.get("cond").isSale is defined and  app.request.get("cond").isSale == 1 ? ' checked="checked"' : "" }} >折扣</label>#}
                {#<label><input type="checkbox" name="cond[isFamous]" value="1" onchange="javascript:__doPostBack('searchCond','')"  {{app.request.get("cond").isFamous is defined and  app.request.get("cond").isFamous == 1 ? ' checked="checked"' : "" }} >品牌</label>#}
            </span>
        </div>
    </div>
{% endblock %}
{% block tableHead %}
    <tr>
        <th width="6%">选择</th>
        <th align="left">产品名称</th>
        <th align="left" width="10%">厂家信息</th>
        <th align="left" width="10%">详细信息</th>
        <th align="left" width="15%">系统标签</th>
        <th align="left" width="10%">产品编号</th>
        <th align="center" width="10%">价格</th>
        <th align="center" width="8%">库存</th>
        <th align="center" width="5%">管理</th>
    </tr>
{% endblock %}
{% block tableList %}
    {% for Product in lists %}
        <tr>
            <td align="center">
                <span class="checkall" style="vertical-align:middle;">
                    <input type="checkbox" name="ids[]" value="{{ Product.id }}"/>
                </span>
            </td>
            <td align="left">{{ Product.name }}</td>
            <td align="left">
                <a href="{{ path("ProductProducePreEdit" , {"id": Product.comId ? Product.comId : 0}) }}">编辑</a>
                {{ Product.company  ? Product.company : "未设置"  }}
            </td>
            <td align="left">

                {% if Product.cover %}
                <a href="{{ path("ProductShowPreEdit" , {"id": Product.showId ? Product.showId : 0}) }}"><img src='{{ Product.cover }}' width='100' height='100' /></a>
                {% else %}
                    <a href="{{ path("ProductShowPreEdit" , {"id": Product.showId ? Product.showId : 0}) }}">编辑</a>
                    未设置
                {% endif %}
            </td>
            <td align="left">
                {% for key,val in choices %}
                    {% if Product[key]  %}
                        <p>{{ val }}：<span style="color:green;">已推荐</span> | <span>设置</span> | <a style="color:red;" href="javascript:__doPostBack('setAttr','id={{ Product.id }}&{{ key }}=0');">取消</a></p>
                    {% else %}
                        <p>{{ val }}：<span style="color:red;">未推荐</span> | <a style="color:green;" href="javascript:__doPostBack('setAttr','id={{ Product.id }}&{{ key }}=1');">设置</a> | <span>取消</span></p>
                    {% endif %}
                {% endfor %}


            </td>
            <td align="left">{{ Product.no }}</td>
            <td align="center">{{ Product.price/100 }}</td>
            <td align="center"><input id="val_{{ Product.id }}" type="text" value="{{ Product.num }}"  class="sort" onkeydown="return checkNumber(event);"  onblur="__doPostBack('setAttr','id={{ Product.id }}&Num='+ $('#val_{{ Product.id }}').val())"></td>
            <td align="center">
                <a href="{{ path("ProductPreEdit",{'id':Product.id}) }}" class="img-btn edit"></a>
            </td>
        </tr>
    {% endfor %}
{% endblock %}
{% block script %}
    {#{% include 'AdminsBundle:base:inc.js.pic.upload.twig' %}#}
    {#{% include 'AdminsBundle:base:inc.js.article.twig' %}#}
    {#{% include 'AdminsBundle:base:inc.js.form.valid.twig' %}#}
    {#{% include 'AdminsBundle:base:inc.js.date.picker.twig' %}#}
{% endblock %}

